import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/home',
    name: 'Home',
    component: () => import('@views/home.vue'),
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@views/login/login.vue')
  },
  {
    path: '/404',
    name: '404',
    component: () => import('@views/404/404.vue')
  },
  // 重定向
  {
    path: '/:pathMatch(.*)*',
    redirect: '/404',
    name: 'Any'
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes,
  // 滚动行为
  scrollBehavior () {
    return {
      top: 0,
      left: 0
    }
  }
})

export default router